package com.hange.ymcc.utils;

import com.alibaba.fastjson.JSON;
import com.hange.ymcc.domain.Login;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

public class LoginContext {
    public static Login getLogin(){
        SecurityContext context = SecurityContextHolder.getContext();
        String principal = context.getAuthentication().getPrincipal().toString();
        Login login = JSON.parseObject(principal, Login.class);
        return login;
    }
}
